<template>
    <div>
        Alert 警告
        <div>
            <template>
            <el-alert
                title="成功提示的文案"
                type="success">
            </el-alert>
            <el-alert
                title="消息提示的文案"
                type="info">
            </el-alert>
            <el-alert
                title="警告提示的文案"
                type="warning">
            </el-alert>
            <el-alert
                title="错误提示的文案"
                type="error">
            </el-alert>
            </template>
        </div>

        Loading 加载
        <div>
            <template>
            <el-table
                v-loading="loading"
                :data="tableData"
                style="width: 100%">
                <el-table-column
                prop="date"
                label="日期"
                width="180">
                </el-table-column>
                <el-table-column
                prop="name"
                label="姓名"
                width="180">
                </el-table-column>
                <el-table-column
                prop="address"
                label="地址">
                </el-table-column>
            </el-table>
            </template>
        </div>

        Message 消息提示
        <div>
            <template>
            <el-button :plain="true" @click="open">打开消息提示</el-button>
            <el-button :plain="true" @click="openVn">VNode</el-button>
            </template>
        </div>

        MessageBox 弹框
        <div>
            <template>
            <el-button type="text" @click="open1">点击打开 Message Box</el-button>
            </template>
        </div>

        Notification 通知
        <div>
            <template>
            <el-button
                plain
                @click="open2">
                可自动关闭
            </el-button>
            <el-button
                plain
                @click="open3">
                不会自动关闭
                </el-button>
            </template>

        </div>
    </div>
</template>

<script>
  export default {
    data() {
      return {
        tableData: [{
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }],
        loading: true
      };
    },
    methods: {
      open() {
        this.$message('这是一条消息提示');
      },

      openVn() {
        const h = this.$createElement;
        this.$message({
          message: h('p', null, [
            h('span', null, '内容可以是 '),
            h('i', { style: 'color: teal' }, 'VNode')
          ])
        });
      },
      open1() {
        this.$alert('这是一段内容', '标题名称', {
          confirmButtonText: '确定',
          callback: action => {
            this.$message({
              type: 'info',
              message: `action: ${ action }`
            });
          }
        });
      },
      open2() {
        const h = this.$createElement;

        this.$notify({
          title: '标题名称',
          message: h('i', { style: 'color: teal'}, '这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案')
        });
      },

      open3() {
        this.$notify({
          title: '提示',
          message: '这是一条不会自动关闭的消息',
          duration: 0
        });
      }
    }
  };
</script>
